package com.szeldon.pj.jps.exp;

import com.szeldon.pj.jps.data.store.SBAStore;
import com.szeldon.pj.jps.datastore.SimpleObject;
import com.szeldon.pj.jps.envs.ENVS;
import com.szeldon.pj.jps.qres.AbstractQueryResult;
import com.szeldon.pj.jps.qres.IntegerResult;
import com.szeldon.pj.jps.qres.QResStack;
import com.szeldon.pj.jps.visitor.ASTVisitor;

public class CountNaryExpression extends NaryExpression {

	/**
	 * 
	 * @param expressions
	 */
	public CountNaryExpression(Expression... expressions) {
		super(expressions);
	}

	@Override
	public int compareTo(SimpleObject object) throws IllegalStateException {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public String getValueAsString() {
		// TODO Auto-generated method stub
		return null;
	}

	public void accept(ASTVisitor astVisitor, ENVS envs, QResStack qResStack, SBAStore store) {

		int count = 0;

		for (Expression currentExpression : expressions) {
			astVisitor.accept(currentExpression);
			AbstractQueryResult currentResult = qResStack.pop();

			count++;
		}

		qResStack.push(new IntegerResult(count));
	}

}
